home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 10 Jan 1996 17:51:15 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4d0uaj$i4i@maureen.teleport.com>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <OWhVx*42f@yaps.rhein.de> <4cuhng$dmn@maureen.teleport.com> <jasonb.821247870@cs.uwa.edu.au>
- NNTP-Posting-Host: julie.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
- : sschaem@teleport.com (Stephan Schaem) writes:
- : >Arno Eigenwillig (arno@yaps.rhein.de) wrote:
- : >: Why don't you read what he wrote? A reasonable example for that would
- : >: be operations on clock_t.
-
- : > The claim was general: you can forget your variable type when you use
- : > them in C... I'm just saying thats its not wise.
-
- : What we've been (repeatedly) trying to say, is that's *not* what he
- : said. He said you can forget about the *implementation* of your
- : variable type on a particular machine (if the data is encapsulated
- : correctly). The whole point being that in assembler, you cannot forget
- : the implementation, because pratically every time you do *use* a
- : "variable" of that type, you have to specify how big it is.
-
- Nope you specify its type... when I decalre my variable in ASM I choose
- a type... char, word, long, float, double, pointer, ...
-
- I can tell you that in asm or C I dont care a bunch of the float format,
- but I care about its range... When I have a routine with float and long
- I keep track wich is wich otherwise I will write crap (In C or asm)
-
- This is why I think like I think when I write C or asm.
-
- : >: Why don't you read what he wrote? You use clock_t and treat it as a
- : >: 'black box'. As you never name the underlying type, you are fully
- : >: portable.
-
- : > What if clock_t is on other system a pointer to a bcpl string?
-
- : Unfortunately that will not work, because clock_t isn't sufficiently
- : encapsulated - ie. to find the difference between two clock_t values,
- : you must use "-", and "-" acts as expected only on ordinal types. With
- : C++, however, "-" can be overloaded to work with *any* definition of
- : clock_t, including BCPL strings.
-
- Yes, but you cant put c++ to prove the point that 'C programmer'
- dont need to know there variable type, and there variable type
- definition...
-
- : For a better example, look at time_t. It comes with a full suite of
- : support functions that effectively hide its implementation from you.
- : So it could well be implemented as a BCPL string right now without
- : causing any problems (at least for programmers who don't see it's eg.
- : a long and try to use "-" to find differences in time instead of
- : difftime()).
-
- Yes... I do that in asm and C too...
-
- : >: Name an existing assembler that allows such things.
-
- : > You can write yourself a simple preprocessor that will do a search replace
- : > using a mytype.typedef file... The point I wanted to make is this:
- : > [Store variable of type A, into variable of type A]
- : > This is what I think when I write
- : > chipreg->bltcon0 = con0;
- : > [Store con0 of type CHIPREG, into chipreg.bltcon0 of type CHIPREG]
- : > &
- : > move.w (GLOBAL_con0_w,a4),(CHIPREG_bltcon0_w,a1)
- : > [Store con0 of type WORD, into chipreg.bltcon0 of type WORD]
- : > here I just happen to know WORD is 2 byte.. but so what.
-
- : Again, the "so what" is that in assembler, you're using the knowledge
- : that CHIPREG is a WORD - as soon as you do that, you've tied yourself
- : to only one implementation of CHIPREG.
-
- I never said that C typedef was bad and not an advantage over C? did I?
- that was not was I was trying to say... I was trying to say that the
- thinking process in C or asm here is the same.
-
- Now if I want to write
- bltcon0 |= defaultbltcon0; I better know what CHIPREG is about.
-
- Stephan
-